package com.example.linuxchat;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.widget.TextView;

import com.example.linuxchat.bean.User;
import com.loopj.android.image.SmartImageView;

public class UserInfoActivity extends AppCompatActivity {
    protected Toolbar toolbar;
    private TextView textInfo=null;
    private SmartImageView head=null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_info);
        setActionBar();
        textInfo=(TextView)findViewById(R.id.infoText);
        head=(SmartImageView) findViewById(R.id.headImage);

        SharedPreferences sp=getSharedPreferences("user_info", Context.MODE_PRIVATE);
        String id=sp.getString("id",null);
        String name=sp.getString("nickname",null);
        String imageUrl=sp.getString("url",null);
        String gender=sp.getString("gender",null);
        String city=sp.getString("city",null);
        String is_yellow_vip=sp.getString("is_yellow_vip",null);
        String province=sp.getString("province",null);
        String vip=sp.getString("vip",null);
        String year=sp.getString("year",null);

        //设置头像等信息
        head.setImageUrl(imageUrl);
        textInfo.setText("");
        textInfo.append(name+"\n");
        textInfo.append(gender+"\n");
        textInfo.append(province+"\n");
        textInfo.append(city+"\n");
        textInfo.append(year+"\n");
//        textInfo.append(user.getId());

        if(is_yellow_vip.equals("0"))
            textInfo.append("否\n");
        else
            textInfo.append("是\n");

        if(vip.equals("0"))
            textInfo.append("否\n");
        else
            textInfo.append("是\n");
    }

    //设置状态栏
    protected void setActionBar(){
        toolbar=(Toolbar)findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        System.out.println(toolbar.hashCode());
        ActionBar actionBar=getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle("");
    }
    @Override
    public boolean onOptionsItemSelected( MenuItem item) {
        switch (item.getItemId()){
            case android.R.id.home:
                finish();
                return true;

        }
        return super.onOptionsItemSelected(item);
    }
}
